﻿using System;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NUnit.Framework;
using OurSite.Business;
using OurSite.Business.Repositories;


namespace OurSite.Tests
{
    [TestFixture]
    public class UserRepository_Fixture
    {
        [TestFixtureSetUp]
        public void TestFixtureSetUp()
        {
            NHibernateSessionManager.Instance.Initialize();
        }

        [Test]
        public void Can_get_User_by_UserName_and_Password()
        {
            IUserRepository repository = new UserRepository();
            var user = repository.GetByUserName("harden06", "harden06");

            Assert.IsNotNull(user);
            Assert.AreEqual("Guest", user.FirstName);
        }

        [Test]
        public void Can_get_Role_by_RoleName()
        {
            IRoleRepository repository = new RoleRepository();
            var role = repository.GetByRoleName("READER");

            Assert.IsNotNull(role);
            Assert.AreEqual("READER", role.RoleName);
        }
    }
}
